<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />









  <meta name="baidu-site-verification" content="Q7ugSRSO7V" />







  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="数据转换Jsonxml转json$msg = (array)simplexml_load_string($postStr, &apos;SimpleXMLElement&apos;, LIBXML_NOCDATA); 生成器语法 官网解释demo：&amp;lt;?phpfunction gen_one_three() &amp;#123;    for ($i = 0; $i &amp;lt; 5; $i++) &amp;#123;">
<meta property="og:type" content="article">
<meta property="og:title" content="chimps">
<meta property="og:url" content="http://yoursite.com/php/类与对象/index.html">
<meta property="og:site_name" content="chimps">
<meta property="og:description" content="数据转换Jsonxml转json$msg = (array)simplexml_load_string($postStr, &apos;SimpleXMLElement&apos;, LIBXML_NOCDATA); 生成器语法 官网解释demo：&amp;lt;?phpfunction gen_one_three() &amp;#123;    for ($i = 0; $i &amp;lt; 5; $i++) &amp;#123;">
<meta property="og:updated_time" content="2017-04-23T14:35:35.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="chimps">
<meta name="twitter:description" content="数据转换Jsonxml转json$msg = (array)simplexml_load_string($postStr, &apos;SimpleXMLElement&apos;, LIBXML_NOCDATA); 生成器语法 官网解释demo：&amp;lt;?phpfunction gen_one_three() &amp;#123;    for ($i = 0; $i &amp;lt; 5; $i++) &amp;#123;">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"hide","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":30},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/php/类与对象/"/>





  <title>  | chimps </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?dcb994042608bdb310eff950ba755ff1";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">chimps</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/php/类与对象/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="chimps">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://sfault-avatar.b0.upaiyun.com/416/326/4163260007-58a1621e63a68_huge256">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chimps">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-23T22:34:33+08:00">
                2017-04-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/php/" itemprop="url" rel="index">
                    <span itemprop="name">php</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a class="cloud-tie-join-count" href="/php/类与对象/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count join-count" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="数据转换Json"><a href="#数据转换Json" class="headerlink" title="数据转换Json"></a>数据转换Json</h1><h2 id="xml转json"><a href="#xml转json" class="headerlink" title="xml转json"></a>xml转json</h2><figure class="highlight php"><table><tr><td class="code"><pre><div class="line">$msg = (<span class="keyword">array</span>)simplexml_load_string($postStr, <span class="string">'SimpleXMLElement'</span>, LIBXML_NOCDATA);</div></pre></td></tr></table></figure>
<h1 id="生成器语法"><a href="#生成器语法" class="headerlink" title="生成器语法"></a>生成器语法</h1><blockquote>
<p><a href="http://de2.php.net/manual/zh/language.generators.syntax.php# control-structures.yield" target="_blank" rel="external">官网解释</a><br>demo：<br><figure class="highlight php"><table><tr><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">gen_one_three</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">for</span> ($i = <span class="number">0</span>; $i &lt; <span class="number">5</span>; $i++) &#123;</div><div class="line">        <span class="keyword">echo</span> <span class="string">"yield"</span> . $i . <span class="string">"  "</span>;</div><div class="line">        <span class="comment">//注意变量$i的值在不同的yield之间是保持传递的。</span></div><div class="line">        <span class="keyword">yield</span> $i;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line">$generate = gen_one_three();</div><div class="line"><span class="keyword">foreach</span> ($generate <span class="keyword">as</span> $item) &#123;</div><div class="line">    <span class="keyword">echo</span> <span class="string">"item"</span> . $item . <span class="string">"\n"</span>;</div><div class="line">&#125;</div><div class="line"><span class="comment">// 结果：</span></div><div class="line">yield0  item0</div><div class="line">yield1  item1</div><div class="line">yield2  item2</div><div class="line">yield3  item3</div><div class="line">yield4  item4</div></pre></td></tr></table></figure></p>
<p>　　当一个生成器被调用的时候，它返回一个可以被遍历的对象.当你遍历这个对象的时候(例如通过一个foreach循环)，PHP 将会在每次需要值的时候调用生成器函数，并在产生一个值之后保存生成器的状态，这样它就可以在需要产生下一个值的时候恢复调用状态。</p>
<h1 id="反射机制"><a href="#反射机制" class="headerlink" title="反射机制"></a>反射机制</h1><h2 id="基本特性"><a href="#基本特性" class="headerlink" title="基本特性"></a>基本特性</h2><pre><code>PHP 5 具有完整的反射 API，添加了对类、接口、函数、方法和扩展进行反向工程的能力。 此外，反射 API 提供了方法来取出函数、类和方法中的文档注释。
它是指在PHP运行状态中，扩展分析PHP程序，导出或提取出关于类、方法、属性、参数等的详细信息，包括注释。这种动态获取的信息以及动态调用对象的方法的功能称为反射API。反射是操纵面向对象范型中元模型的API，其功能十分强大，可帮助我们构建复杂，可扩展的应用。
其用途如：自动加载插件，自动生成文档，甚至可用来扩充PHP语言。
反射api是php内建的oop技术扩展，包括一些类，异常和接口，综合使用他们可用来帮助我们分析其它类，接口，方法，属性，方法和扩展。这些oop扩展被称为反射。
</code></pre></blockquote>
<ul>
<li><p>通过ReflectionClass，我们可以得到一个类的以下信息：</p>
<ol>
<li>常量 Contants</li>
<li>属性 Property Names</li>
<li>方法 Method Names静态</li>
<li>属性 Static Properties</li>
<li>命名空间 Namespace</li>
<li>类是否为final或者abstract</li>
</ol>
</li>
<li><p>接下来反射它，只要把类名”Person”传递给ReflectionClass就可以了：</p>
<figure class="highlight php"><table><tr><td class="code"><pre><div class="line">$class = <span class="keyword">new</span> ReflectionClass(<span class="string">'Person'</span>);<span class="comment">//建立 Person这个类的反射类  </span></div><div class="line">$instance  = $class-&gt;newInstanceArgs($args);<span class="comment">//相当于实例化Person 类</span></div></pre></td></tr></table></figure>
</li>
<li><p>获取属性(Properties)：</p>
<figure class="highlight php"><table><tr><td class="code"><pre><div class="line">$properties = $class-&gt;getProperties();  </div><div class="line"><span class="keyword">foreach</span>($properties <span class="keyword">as</span> $property) &#123;  </div><div class="line">    <span class="keyword">echo</span> $property-&gt;getName().<span class="string">"\n"</span>;  </div><div class="line">&#125;  </div><div class="line"><span class="comment">// 输出:  </span></div><div class="line"><span class="comment">// _allowDynamicAttributes  </span></div><div class="line"><span class="comment">// id  </span></div><div class="line"><span class="comment">// name  </span></div><div class="line"><span class="comment">// biography</span></div></pre></td></tr></table></figure>
</li>
<li><p>获取注释：</p>
<figure class="highlight php"><table><tr><td class="code"><pre><div class="line"><span class="keyword">foreach</span>($properties <span class="keyword">as</span> $property) &#123;  </div><div class="line">    <span class="keyword">if</span>($property-&gt;isProtected()) &#123;  </div><div class="line">        $docblock = $property-&gt;getDocComment();  </div><div class="line">        preg_match(<span class="string">'/ type\=([a-z_]*) /'</span>, $property-&gt;getDocComment(), $matches);  </div><div class="line">        <span class="keyword">echo</span> $matches[<span class="number">1</span>].<span class="string">"\n"</span>;  </div><div class="line">    &#125;  </div><div class="line">&#125;  </div><div class="line"><span class="comment">// Output:  </span></div><div class="line"><span class="comment">// primary_autoincrement  </span></div><div class="line"><span class="comment">// varchar  </span></div><div class="line"><span class="comment">// text</span></div></pre></td></tr></table></figure>
</li>
<li><p>获取类的方法</p>
</li>
</ul>
<blockquote>
<p>获取方法(methods)：通过<code>getMethods()</code>来获取到类的所有methods。</p>
</blockquote>
<ul>
<li>执行类的方法：<figure class="highlight php"><table><tr><td class="code"><pre><div class="line">$instance-&gt;getBiography(); <span class="comment">//执行Person 里的方法getBiography  </span></div><div class="line"><span class="comment">//或者：  </span></div><div class="line">$ec=$class-&gt;getmethod(<span class="string">'getName'</span>);  <span class="comment">//获取Person 类中的getName方法  </span></div><div class="line">$ec-&gt;invoke($instance);       <span class="comment">//执行getName 方法</span></div></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="实际应用"><a href="#实际应用" class="headerlink" title="实际应用"></a>实际应用</h2><figure class="highlight php"><table><tr><td class="code"><pre><div class="line"><span class="comment">// container类</span></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">container</span> </span>&#123;</div><div class="line">    <span class="keyword">public</span> $binds;</div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * <span class="doctag">@param</span> string $abstract 接口名</div><div class="line">     * <span class="doctag">@param</span> string $concrete 实例名</div><div class="line">     */</div><div class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">bind</span><span class="params">($abstract, $concrete)</span> </span>&#123;</div><div class="line">        <span class="keyword">$this</span>-&gt;binds[$abstract] = $concrete;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * <span class="doctag">@param</span> string $className 接口或实例名</div><div class="line">     * <span class="doctag">@return</span> object 根据接口或对象,返回实例化后的对象</div><div class="line">     * <span class="doctag">@throws</span> \Exception</div><div class="line">     */</div><div class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">build</span><span class="params">($className)</span> </span>&#123;</div><div class="line">        <span class="comment">// 如果是回调函数,则直接调用</span></div><div class="line">        <span class="keyword">if</span> ($className <span class="keyword">instanceof</span> \Closure) &#123;</div><div class="line">            <span class="keyword">return</span> $className();</div><div class="line">        &#125;</div><div class="line">        <span class="comment">// 创建反射类</span></div><div class="line">        $reflector = <span class="keyword">new</span> \ReflectionClass($className);</div><div class="line">        <span class="comment">// 如果是接口,则查找对应的绑定实例</span></div><div class="line">        <span class="keyword">if</span> ($reflector-&gt;isInterface()) &#123;</div><div class="line">            <span class="keyword">if</span> (<span class="keyword">isset</span>(<span class="keyword">$this</span>-&gt;binds[$className])) &#123;</div><div class="line">                <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;build(<span class="keyword">$this</span>-&gt;binds[$className]);</div><div class="line">            &#125; <span class="keyword">else</span> &#123;</div><div class="line">                <span class="keyword">throw</span> <span class="keyword">new</span> \<span class="keyword">Exception</span>($className . <span class="string">'接口没有对应实现'</span>);</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        <span class="comment">// 不能实例化，抛异常</span></div><div class="line">        <span class="keyword">if</span> (!$reflector-&gt;isInstantiable()) &#123;</div><div class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> \<span class="keyword">Exception</span>(<span class="string">"Target [$className] is not instantiable."</span>);</div><div class="line">        &#125;</div><div class="line">        <span class="comment">// 创建构造器</span></div><div class="line">        $constructor = $reflector-&gt;getConstructor();</div><div class="line">        <span class="comment">// 没有构造函数</span></div><div class="line">        <span class="keyword">if</span> ($constructor === <span class="keyword">null</span>) &#123;</div><div class="line">            <span class="keyword">return</span> <span class="keyword">new</span> $className;</div><div class="line">        &#125;</div><div class="line">        <span class="comment">// 获取构造函数参数</span></div><div class="line">        $dependencies = $constructor-&gt;getParameters();</div><div class="line">        <span class="comment">// 获取依赖实例对象</span></div><div class="line">        $instances = <span class="keyword">$this</span>-&gt;getDependencies($dependencies);</div><div class="line">        <span class="comment">// 实例化对象</span></div><div class="line">        <span class="keyword">return</span> $reflector-&gt;newInstanceArgs($instances);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * <span class="doctag">@param</span> array $parameters 获取依赖</div><div class="line">     * <span class="doctag">@return</span> array</div><div class="line">     * <span class="doctag">@throws</span> \Exception</div><div class="line">     */</div><div class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">getDependencies</span><span class="params">(array $parameters)</span> </span>&#123;</div><div class="line">        $dependencies = [];</div><div class="line"></div><div class="line">        <span class="keyword">foreach</span> ($parameters <span class="keyword">as</span> $parameter) &#123;</div><div class="line">            $dependency = $parameter-&gt;getClass();</div><div class="line">            <span class="keyword">if</span> ($dependency) &#123;</div><div class="line">                $dependencies[] = <span class="keyword">$this</span>-&gt;build($dependency-&gt;name);</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">return</span> (<span class="keyword">array</span>)$dependencies;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">// 项目启动文件</span></div><div class="line"><span class="meta">&lt;?php</span></div><div class="line"></div><div class="line"><span class="keyword">namespace</span> <span class="title">core</span>;</div><div class="line"></div><div class="line"><span class="keyword">use</span> <span class="title">core</span>\<span class="title">lib</span>\<span class="title">container</span>;</div><div class="line"><span class="keyword">use</span> <span class="title">core</span>\<span class="title">lib</span>\<span class="title">provider</span>;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">ying</span> </span>&#123;</div><div class="line">    <span class="keyword">public</span> <span class="keyword">static</span> $classMap = [];</div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 初始化入口方法</div><div class="line">     * 路由匹配</div><div class="line">     */</div><div class="line">    <span class="keyword">static</span> <span class="function"><span class="keyword">function</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</div><div class="line">        \core\lib\log::init();</div><div class="line">        $route = <span class="keyword">new</span> \core\lib\route();</div><div class="line">        $ctrl = $route-&gt;ctrl;</div><div class="line">        $action = $route-&gt;action;</div><div class="line">        $ctrl_file = APP . <span class="string">'/ctrl/'</span> . $ctrl . <span class="string">'Ctrl.php'</span>;</div><div class="line">        $ctrl_class = <span class="string">'\\'</span> . MODULE . <span class="string">'\ctrl\\'</span> . $ctrl . <span class="string">'Ctrl'</span>;</div><div class="line">        </div><div class="line">        <span class="keyword">if</span> (is_file($ctrl_file)) &#123;</div><div class="line">            $container = <span class="keyword">new</span> container();</div><div class="line">            provider::register($container);</div><div class="line">            <span class="comment">// 服务启动</span></div><div class="line">            $ctrl_obj = $container-&gt;build($ctrl_class);</div><div class="line">            $ctrl_obj-&gt;$action();</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 自动加载方法</div><div class="line">     */</div><div class="line">    <span class="keyword">static</span> <span class="function"><span class="keyword">function</span> <span class="title">load</span><span class="params">($class)</span> </span>&#123;</div><div class="line">        <span class="keyword">if</span> (<span class="keyword">isset</span>($classMap[$class])) &#123;</div><div class="line">            <span class="keyword">return</span> <span class="keyword">true</span>;</div><div class="line">        &#125; <span class="keyword">else</span> &#123;</div><div class="line">            $class = str_replace(<span class="string">'\\'</span>, <span class="string">'/'</span>, $class);</div><div class="line">            $file = YING . $class . <span class="string">'.php'</span>;</div><div class="line">            <span class="keyword">if</span> (is_file($file)) &#123;</div><div class="line">                <span class="keyword">include</span> $file;</div><div class="line">                <span class="keyword">self</span>::$classMap[$class] = $file;</div><div class="line">            &#125; <span class="keyword">else</span> &#123;</div><div class="line">                <span class="keyword">return</span> <span class="keyword">false</span>;</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/php/pdo/" rel="next" title="pdo">
                <i class="fa fa-chevron-left"></i> pdo
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/php/配置/" rel="prev" title="配置">
                配置 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="https://sfault-avatar.b0.upaiyun.com/416/326/4163260007-58a1621e63a68_huge256"
               alt="chimps" />
          <p class="site-author-name" itemprop="name">chimps</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">59</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">12</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">19</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#数据转换Json"><span class="nav-number">1.</span> <span class="nav-text">数据转换Json</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#xml转json"><span class="nav-number">1.1.</span> <span class="nav-text">xml转json</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#生成器语法"><span class="nav-number">2.</span> <span class="nav-text">生成器语法</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#反射机制"><span class="nav-number">3.</span> <span class="nav-text">反射机制</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#基本特性"><span class="nav-number">3.1.</span> <span class="nav-text">基本特性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#实际应用"><span class="nav-number">3.2.</span> <span class="nav-text">实际应用</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">chimps</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  








  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  




	





  
    
    <script>
      var cloudTieConfig = {
        url: document.location.href, 
        sourceId: "",
        productKey: "48bb30d8783d4b38ba0c95e0283238ca",
        target: "cloud-tie-wrapper"
      };
    </script>
    <script src="https://img1.ws.126.net/f2e/tie/yun/sdk/loader.js"></script>
  










  





  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

  

</body>
</html>
